﻿using System;
using System.Collections.Generic;
using System.Text;

    
public static class CommonFunctions
{
    //private static int[] numberValues = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
    private static Char[] charValues = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };


    public static int FindItemByName(List<Food> foodList,string itemName)
    {
        int i = 0;
        for (; i < foodList.Count; ++i)
        {
            if (itemName == foodList[i].Name) break;
        }
        if (i == (foodList.Count)) i = -1;
        return i;
    }


    public static string To36Based(int decimalValue)
    {
        string returnValue = "";

        int integerPart = decimalValue;
        int remainder = 0;

        do
        {
            remainder = integerPart % 36;
            integerPart -= remainder;
            integerPart /= 36;
            
            returnValue = charValues[remainder] + returnValue;
        }
        while (integerPart > 0);

        return returnValue;
    }
}
